package com.csot.ry.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.csot.common.annotation.Log;
import com.csot.common.core.controller.BaseController;
import com.csot.common.core.domain.AjaxResult;
import com.csot.common.enums.BusinessType;
import com.csot.ry.domain.TAssetIdleIp;
import com.csot.ry.service.ITAssetIdleIpService;
import com.csot.common.utils.poi.ExcelUtil;
import com.csot.common.core.page.TableDataInfo;

/**
 * 资产空闲ipController
 * 
 * @author csot
 * @date 2025-07-12
 */
@RestController
@RequestMapping("/asset/assetidleip")
public class TAssetIdleIpController extends BaseController
{
    @Autowired
    private ITAssetIdleIpService tAssetIdleIpService;

    /**
     * 查询资产空闲ip列表
     */
    @PreAuthorize("@ss.hasPermi('asset:assetidleip:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAssetIdleIp tAssetIdleIp)
    {
        startPage();
        List<TAssetIdleIp> list = tAssetIdleIpService.selectTAssetIdleIpList(tAssetIdleIp);
        return getDataTable(list);
    }

    /**
     * 导出资产空闲ip列表
     */
    @PreAuthorize("@ss.hasPermi('asset:assetidleip:export')")
    @Log(title = "资产空闲ip", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAssetIdleIp tAssetIdleIp)
    {
        List<TAssetIdleIp> list = tAssetIdleIpService.selectTAssetIdleIpList(tAssetIdleIp);
        ExcelUtil<TAssetIdleIp> util = new ExcelUtil<TAssetIdleIp>(TAssetIdleIp.class);
        util.exportExcel(response, list, "资产空闲ip数据");
    }

    /**
     * 获取资产空闲ip详细信息
     */
    @PreAuthorize("@ss.hasPermi('asset:assetidleip:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tAssetIdleIpService.selectTAssetIdleIpById(id));
    }

    /**
     * 新增资产空闲ip
     */
    @PreAuthorize("@ss.hasPermi('asset:assetidleip:add')")
    @Log(title = "资产空闲ip", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAssetIdleIp tAssetIdleIp)
    {
        return toAjax(tAssetIdleIpService.insertTAssetIdleIp(tAssetIdleIp));
    }

    /**
     * 修改资产空闲ip
     */
    @PreAuthorize("@ss.hasPermi('asset:assetidleip:edit')")
    @Log(title = "资产空闲ip", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAssetIdleIp tAssetIdleIp)
    {
        return toAjax(tAssetIdleIpService.updateTAssetIdleIp(tAssetIdleIp));
    }

    /**
     * 删除资产空闲ip
     */
    @PreAuthorize("@ss.hasPermi('asset:assetidleip:remove')")
    @Log(title = "资产空闲ip", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tAssetIdleIpService.deleteTAssetIdleIpByIds(ids));
    }
}
